package com.fumin.common;

import com.fumin.pojo.CoinCount;
import com.fumin.pojo.InvestmentRecord;
import com.fumin.pojo.Projects;
import com.fumin.pojo.User;
import com.fumin.service.UserService;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * Created by Lingo on 2018/2/13.
 */
public class CalV1 extends AbstractCalculator implements ICoinCountor {

    private static Integer BASE = 72;
    private static Integer SECOND = 24;
    private static Integer THIRD= 8;

    @Override
    public List<CoinCount> countCoin(List<User> user) {
        List<CoinCount> cache = makeResult(user);
//        for (CoinCount temp:cache) {
//            if (temp.getLevel()==0){
//                temp.setCount(BASE);
//            }else if(temp.getLevel()==1){
//                temp.setCount(SECOND);
//            }else if(temp.getLevel()==2){
//                temp.setCount(THIRD);
//            }
//        }
        return cache;
    }

    @Override
    public List<CoinCount> countCoinByInventRecords(InvestmentRecord investmentRecord,
                                                    Projects projects,
                                                    UserService userService) {
        List<CoinCount> list = new LinkedList<>();
        Map<String,String> strFathersPk = userService.selectAllFatherUsers(investmentRecord.getUser_id());
        String [] strFathers = strFathersPk.get("fathers").split(",");
        // 根据项目名称/投资记录/用户层级/生成奖励记录
        list.add(CountCointFactory.getCountCoin(2,strFathers[2],projects,investmentRecord));
        list.add(CountCointFactory.getCountCoin(3,strFathers[3],projects,investmentRecord));
        return list;
    }
}
